package com.zhangtai.modules.dao;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhangtai.modules.dto.SecurityDto;
import com.zhangtai.modules.entity.system.ContractSubGroupEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 合同主体组子表

 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-11-27 16:33:34
 */
@Mapper
public interface ContractSubGroupDao extends BaseMapper<ContractSubGroupEntity> {

    @Delete("DELETE FROM sys_contract_sub_group WHERE contract_group_id = #{contractGroupId}")
    public void deleteContractSubGroup(@Param("contractGroupId") Long contractGroupId);


    @Select("SELECT * from sys_contract_sub_group WHERE contract_group_id = #{contractGroupId}")
    public List<ContractSubGroupEntity> getSubContractList(@Param("contractGroupId") Long contractGroupId);


    @Select("<script>SELECT " +
            "t1.*" +
            "FROM " +
            " sys_contract_sub_group t1 " +
            "<where> t1.is_delete = 0   " +
            "AND t1.contract_group_id IN"+
            "<foreach collection=\"contractIds\" item=\"item\" index=\"index\" "+
            "open=\"(\" separator=\",\" close=\")\">"+
            "#{item}"+
            "</foreach>"+
            "</where>" +
            "</script>")
    List<ContractSubGroupEntity> getContractMainIds(@Param(value = "contractIds") List<Long> contractIds);
}